package demo02

import java.io.{File, PrintWriter}

import scala.io.Source

/**
 * @author xiaoZhao
 * @date 2022/6/20
 * @describe 文件输入输出
 */
object Test05_FileIO {
  def main(args: Array[String]): Unit = {
    // 1.从文件中读取数据
    Source.fromFile("src/main/resources/test.txt").foreach(print)

    // 2。将数据写入文件
    val writer = new PrintWriter(new File("src/main/resources/put.txt"))
    writer.write("hello scala from java")
    writer.close()
  }
}
